/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package VIEW.OLD;

import BEANS.ComboItem;
import CONTROLLERS.SecHandTradeInController;
import UTIL.InputValidator;
import VIEW.ProductTrade;
import java.awt.event.KeyEvent;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTable;

/**
 *
 * @author weak_2030
 */
public class SecondhandTradeIn extends javax.swing.JPanel {
        private static SecHandTradeInController secHandTradeInController;
        ProductTrade productTrade;
        
        
    /**
     * Creates new form SecondhandTradeIn
     */
        
    public SecondhandTradeIn() {
        try{
        initComponents();
        //secHandTradeInController = new SecHandTradeInController(secondHandProductsListTable, itemNameInput, descriptionInput, secondHandCategoryComboBox, swapHistoryTable, dateOfSwap, swapToNewDialog, inventoryTableTrade, productNameSwapInput, productDescriptionSwapInput, categoryInput, dateSwappedInput, inventoryTableSearchInput, clear, editDialog, inputName, inputDescription, categoryEditComboBox, receiptNumberInput, serialNumberInput, serialNumberInputDialog);
        InputValidator.enabler(secondHandProductsListTable, TradeButton);
        InputValidator.enabler(secondHandProductsListTable, jButton1);
        this.productTrade = new ProductTrade();
        swapToNewDialog.setLocationRelativeTo(null);
        swapHistory.setLocationRelativeTo(null);
        serialNumberInputDialog.setLocationRelativeTo(null);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        swapHistory = new javax.swing.JDialog();
        jScrollPane2 = new javax.swing.JScrollPane();
        swapHistoryTable = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        swapToNewDialog = new javax.swing.JDialog();
        jScrollPane3 = new javax.swing.JScrollPane();
        inventoryTableTrade = new javax.swing.JTable();
        jLabel7 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        productNameSwapInput = new javax.swing.JLabel();
        productDescriptionSwapInput = new javax.swing.JLabel();
        dateSwappedInput = new javax.swing.JLabel();
        categoryInput = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        receiptNumberInput = new javax.swing.JTextField();
        clear = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        inventoryTableSearchInput = new javax.swing.JTextField();
        editDialog = new javax.swing.JDialog();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        inputName = new javax.swing.JTextField();
        inputDescription = new javax.swing.JTextField();
        saveButton = new javax.swing.JButton();
        cancelEditButton = new javax.swing.JButton();
        categoryEditComboBox = new javax.swing.JComboBox<ComboItem>();
        serialNumberInputDialog = new javax.swing.JDialog();
        jLabel17 = new javax.swing.JLabel();
        serialNumberInput = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        itemNameInput = new javax.swing.JTextField();
        secondHandCategoryComboBox = new javax.swing.JComboBox<ComboItem>();
        jLabel2 = new javax.swing.JLabel();
        descriptionInput = new javax.swing.JTextField();
        addToItemListButton = new javax.swing.JButton();
        tradeToBrandNew = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        secondHandProductsListTable = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        TradeButton = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        dateOfSwap = new datechooser.beans.DateChooserCombo();

        swapHistory.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        swapHistory.setBounds(new java.awt.Rectangle(0, 0, 750, 500));

        swapHistoryTable.setAutoCreateRowSorter(true);
        swapHistoryTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Date swapped", "Customer Item", "Description", "Swapped Item"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(swapHistoryTable);

        jLabel3.setText("Secondhand swap history");

        javax.swing.GroupLayout swapHistoryLayout = new javax.swing.GroupLayout(swapHistory.getContentPane());
        swapHistory.getContentPane().setLayout(swapHistoryLayout);
        swapHistoryLayout.setHorizontalGroup(
            swapHistoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(swapHistoryLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(swapHistoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 931, Short.MAX_VALUE)
                    .addGroup(swapHistoryLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        swapHistoryLayout.setVerticalGroup(
            swapHistoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, swapHistoryLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 483, Short.MAX_VALUE)
                .addContainerGap())
        );

        swapToNewDialog.setBounds(new java.awt.Rectangle(0, 0, 900, 650));

        inventoryTableTrade.setAutoCreateRowSorter(true);
        inventoryTableTrade.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        inventoryTableTrade.setForeground(new java.awt.Color(51, 51, 51));
        inventoryTableTrade.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "product_id", "Product Name", "Category", "Supplier", "Quantity", "Reorder Quantity", "warranty"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        inventoryTableTrade.setGridColor(new java.awt.Color(204, 204, 204));
        inventoryTableTrade.setRowHeight(20);
        inventoryTableTrade.setSelectionForeground(new java.awt.Color(0, 0, 0));
        jScrollPane3.setViewportView(inventoryTableTrade);
        if (inventoryTableTrade.getColumnModel().getColumnCount() > 0) {
            inventoryTableTrade.getColumnModel().getColumn(4).setMaxWidth(70);
            inventoryTableTrade.getColumnModel().getColumn(5).setMaxWidth(70);
        }

        jLabel7.setText("Products Available for Swap");

        jButton4.setText("Cancel");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("OK");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel8.setText("Item being swapped");

        jLabel9.setText("Product Name:");

        jLabel10.setText("Description:");

        jLabel11.setText("Date swapped: ");

        jLabel12.setText("Category:");

        productNameSwapInput.setText("jLabel13");

        productDescriptionSwapInput.setText("jLabel14");

        dateSwappedInput.setText("jLabel15");

        categoryInput.setText("jLabel16");

        jLabel13.setText("Enter receipt number:");

        clear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/UI ICONS/xmark.png"))); // NOI18N
        clear.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                clearMouseClicked(evt);
            }
        });

        jButton6.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButton6.setText("Search");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        inventoryTableSearchInput.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        inventoryTableSearchInput.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                inventoryTableSearchInputKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout swapToNewDialogLayout = new javax.swing.GroupLayout(swapToNewDialog.getContentPane());
        swapToNewDialog.getContentPane().setLayout(swapToNewDialogLayout);
        swapToNewDialogLayout.setHorizontalGroup(
            swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(swapToNewDialogLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, swapToNewDialogLayout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jButton5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton4))
                            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(0, 731, Short.MAX_VALUE))))
                    .addGroup(swapToNewDialogLayout.createSequentialGroup()
                        .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                .addGap(19, 19, 19)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(receiptNumberInput, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                                .addComponent(jLabel9)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(productNameSwapInput, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                                .addComponent(jLabel10)
                                                .addGap(18, 18, 18)
                                                .addComponent(productDescriptionSwapInput, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(48, 48, 48)
                                        .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel11)
                                            .addComponent(jLabel12))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(categoryInput, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(dateSwappedInput, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                        .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(inventoryTableSearchInput, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                                                .addGap(195, 195, 195)
                                                .addComponent(clear, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(5, 5, 5)
                                        .addComponent(jButton6)))))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        swapToNewDialogLayout.setVerticalGroup(
            swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(swapToNewDialogLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(inventoryTableSearchInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(swapToNewDialogLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(clear, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton6))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel11)
                    .addComponent(productNameSwapInput)
                    .addComponent(dateSwappedInput))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel12)
                        .addComponent(categoryInput))
                    .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel10)
                        .addComponent(productDescriptionSwapInput)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(receiptNumberInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 387, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(swapToNewDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(jButton5))
                .addContainerGap())
        );

        clear.setVisible(false);

        editDialog.setBounds(new java.awt.Rectangle(0, 0, 460, 290));

        jLabel14.setText("Product Name:");

        jLabel15.setText("Description:");

        jLabel16.setText("Category:");

        saveButton.setText("Save");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        cancelEditButton.setText("Cancel");
        cancelEditButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelEditButtonActionPerformed(evt);
            }
        });

        categoryEditComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        categoryEditComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Battery", "Tire", "Motor Oil" }));
        categoryEditComboBox.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        categoryEditComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                categoryEditComboBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout editDialogLayout = new javax.swing.GroupLayout(editDialog.getContentPane());
        editDialog.getContentPane().setLayout(editDialogLayout);
        editDialogLayout.setHorizontalGroup(
            editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editDialogLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(inputName)
                    .addComponent(inputDescription)
                    .addComponent(categoryEditComboBox, 0, 189, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, editDialogLayout.createSequentialGroup()
                .addContainerGap(169, Short.MAX_VALUE)
                .addComponent(saveButton)
                .addGap(18, 18, 18)
                .addComponent(cancelEditButton)
                .addGap(100, 100, 100))
        );
        editDialogLayout.setVerticalGroup(
            editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editDialogLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(inputName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(24, 24, 24)
                .addGroup(editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(inputDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addGroup(editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(categoryEditComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(56, 56, 56)
                .addGroup(editDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(saveButton)
                    .addComponent(cancelEditButton))
                .addContainerGap(88, Short.MAX_VALUE))
        );

        serialNumberInputDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        serialNumberInputDialog.setBounds(new java.awt.Rectangle(0, 0, 500, 120));
        serialNumberInputDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);

        jLabel17.setText("Enter Serial Number:");

        jButton3.setText("Cancel");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton7.setText("OK");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout serialNumberInputDialogLayout = new javax.swing.GroupLayout(serialNumberInputDialog.getContentPane());
        serialNumberInputDialog.getContentPane().setLayout(serialNumberInputDialogLayout);
        serialNumberInputDialogLayout.setHorizontalGroup(
            serialNumberInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serialNumberInputDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(serialNumberInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(serialNumberInputDialogLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(serialNumberInput))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, serialNumberInputDialogLayout.createSequentialGroup()
                        .addGap(0, 262, Short.MAX_VALUE)
                        .addComponent(jButton7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)))
                .addContainerGap())
        );
        serialNumberInputDialogLayout.setVerticalGroup(
            serialNumberInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serialNumberInputDialogLayout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addGroup(serialNumberInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(serialNumberInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(serialNumberInputDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton7))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        setBackground(new java.awt.Color(204, 204, 204));
        setToolTipText("");
        setMaximumSize(new java.awt.Dimension(814, 592));
        setPreferredSize(new java.awt.Dimension(814, 592));
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel1.setText("Product Name:");
        add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 110, -1, -1));

        itemNameInput.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        itemNameInput.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemNameInputActionPerformed(evt);
            }
        });
        add(itemNameInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 110, 300, -1));

        secondHandCategoryComboBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        secondHandCategoryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Battery", "Tire", "Motor Oil" }));
        secondHandCategoryComboBox.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        secondHandCategoryComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                secondHandCategoryComboBoxActionPerformed(evt);
            }
        });
        add(secondHandCategoryComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 150, 180, -1));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel2.setText("Description:");
        add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 110, -1, -1));

        descriptionInput.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        descriptionInput.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descriptionInputActionPerformed(evt);
            }
        });
        add(descriptionInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 110, 499, -1));

        addToItemListButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        addToItemListButton.setText("Add to Secondhand Product List");
        addToItemListButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addToItemListButtonActionPerformed(evt);
            }
        });
        add(addToItemListButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 200, -1, 40));

        tradeToBrandNew.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tradeToBrandNew.setText("Trade/Swap to Brand New Product");
        tradeToBrandNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tradeToBrandNewActionPerformed(evt);
            }
        });
        add(tradeToBrandNew, new org.netbeans.lib.awtextra.AbsoluteConstraints(790, 200, -1, 40));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel5.setText("Category:");
        add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, -1, -1));

        secondHandProductsListTable.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        secondHandProductsListTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Product ID", "Product Name", "Description", "Type"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        secondHandProductsListTable.setRowHeight(20);
        jScrollPane1.setViewportView(secondHandProductsListTable);
        secondHandProductsListTable.getColumnModel().getColumn(0).setMaxWidth(0);
        secondHandProductsListTable.getColumnModel().getColumn(0).setMinWidth(0);
        secondHandProductsListTable.getColumnModel().getColumn(0).setPreferredWidth(0);

        add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 260, 1007, 240));

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton1.setText("Edit Product");
        jButton1.setEnabled(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 520, -1, -1));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText(" Trade In");
        add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(11, 11, 1050, -1));

        TradeButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        TradeButton.setText("Trade/Swap Product");
        TradeButton.setEnabled(false);
        TradeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TradeButtonActionPerformed(evt);
            }
        });
        add(TradeButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 200, 186, 40));

        jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton2.setText("View Second Hand Swap History");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(780, 520, -1, -1));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        jLabel4.setText("Date of Swap:");
        add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 150, -1, -1));

        dateOfSwap.setFormat(0);
        add(dateOfSwap, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 150, 240, 30));
    }// </editor-fold>//GEN-END:initComponents

    private void itemNameInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemNameInputActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_itemNameInputActionPerformed

    private void descriptionInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descriptionInputActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_descriptionInputActionPerformed

    private void secondHandCategoryComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_secondHandCategoryComboBoxActionPerformed
        
    }//GEN-LAST:event_secondHandCategoryComboBoxActionPerformed

    private void addToItemListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToItemListButtonActionPerformed

        secHandTradeInController.addSecondHand();
    }//GEN-LAST:event_addToItemListButtonActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        editDialog.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void tradeToBrandNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tradeToBrandNewActionPerformed

    }//GEN-LAST:event_tradeToBrandNewActionPerformed

    private void TradeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TradeButtonActionPerformed
        secHandTradeInController.swapSecondHandToSecondHand();
    }//GEN-LAST:event_TradeButtonActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        swapHistory.setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        secHandTradeInController.checkIfProductHasWarranty();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void clearMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clearMouseClicked
        secHandTradeInController.clearSearch();
    }//GEN-LAST:event_clearMouseClicked

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        secHandTradeInController.searchProduct();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void inventoryTableSearchInputKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inventoryTableSearchInputKeyPressed
        if (evt.getKeyCode()== KeyEvent.VK_ENTER)
        {
            jButton6.doClick();
        }
    }//GEN-LAST:event_inventoryTableSearchInputKeyPressed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        swapToNewDialog.setVisible(false);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        secHandTradeInController.editSelectedItem();
    }//GEN-LAST:event_saveButtonActionPerformed

    private void categoryEditComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_categoryEditComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_categoryEditComboBoxActionPerformed

    private void cancelEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelEditButtonActionPerformed
        editDialog.dispose();
    }//GEN-LAST:event_cancelEditButtonActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        serialNumberInputDialog.dispose();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        secHandTradeInController.swapToNewProduct();
    }//GEN-LAST:event_jButton7ActionPerformed
    
    
    protected static void updateSecondHandTable(){
      secHandTradeInController.updateSecondHandTable();
    }
    
    public static JComboBox<ComboItem> getSecondHandCategoryComboBox(){
        return secondHandCategoryComboBox;
    }
    
    public static JComboBox<ComboItem> getCategoryEditComboBox(){
        return categoryEditComboBox;
    }
    
    public static void updateSecondhandSwapHistoryTable(){
        secHandTradeInController.updateSecondhandSwapHistory();
    }
    public static JTable getProductsTable(){
        return inventoryTableTrade;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton TradeButton;
    private javax.swing.JButton addToItemListButton;
    private javax.swing.JButton cancelEditButton;
    private static javax.swing.JComboBox<ComboItem> categoryEditComboBox;
    private javax.swing.JLabel categoryInput;
    private javax.swing.JLabel clear;
    private datechooser.beans.DateChooserCombo dateOfSwap;
    private javax.swing.JLabel dateSwappedInput;
    private javax.swing.JTextField descriptionInput;
    private javax.swing.JDialog editDialog;
    private javax.swing.JTextField inputDescription;
    private javax.swing.JTextField inputName;
    private javax.swing.JTextField inventoryTableSearchInput;
    private static javax.swing.JTable inventoryTableTrade;
    private javax.swing.JTextField itemNameInput;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JLabel productDescriptionSwapInput;
    private javax.swing.JLabel productNameSwapInput;
    private javax.swing.JTextField receiptNumberInput;
    private javax.swing.JButton saveButton;
    private static javax.swing.JComboBox<ComboItem> secondHandCategoryComboBox;
    private static javax.swing.JTable secondHandProductsListTable;
    private javax.swing.JTextField serialNumberInput;
    private javax.swing.JDialog serialNumberInputDialog;
    private javax.swing.JDialog swapHistory;
    private javax.swing.JTable swapHistoryTable;
    private javax.swing.JDialog swapToNewDialog;
    private javax.swing.JButton tradeToBrandNew;
    // End of variables declaration//GEN-END:variables
}
